package model.backup.handlers;

import database.Database;
import java.sql.SQLException;
import model.User;
import model.backup.BackupProductFamily;
import model.backup.BackupUser;

/**
 * Denne klasse bruges til at hente al data i bs_user og returnere det
 * @author junjie
 */
public abstract class BackupUserHandler {
    
    /**
     * Henter alle rækker i bs_user og returnerer et BackupUser[] model
     * @return BackupUser[]
     * @throws ClassNotFoundException
     * @throws SQLException 
     */
   public static BackupUser[] getBackupUser() throws ClassNotFoundException, SQLException{
       BackupUser[] backupUser = null;
        
        Database db = new Database();
        
        String[][] result = db.getFromDB("bs_user", "", "", "", "id", "username", "password", "email", "securitykey", "access_level");
        backupUser = new BackupUser[result.length];
        
        db.closeDB();
        
        for (int i = 0; i < result.length; i++)
        {
            backupUser[i] = new BackupUser(Integer.parseInt(result[0][0]), result[0][1], result[0][2], result[0][3], result[0][4], Integer.parseInt(result[0][5]));
        }
        
        return backupUser;
   }
}
